package com.edu;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@Component
public class AuthFilter implements GlobalFilter, Ordered {

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        // 在此处实现认证逻辑，例如从请求中获取认证信息进行验证
        // 如果验证失败，可以设置响应并返回
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return -1; // 控制过滤器执行顺序，此处设置为最高优先级
    }
}
